<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="cn.westv.scps.domain.SysUserEntity" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    SysUserEntity sysUser = (SysUserEntity)session.getAttribute("sysUser");
    if (sysUser != null){
        request.getRequestDispatcher("s/sys/user/home.cgi").forward(request,response);
    }
%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>欢迎登录城市安全管家代理终端</title>
</head>
<body>
<script src="common/script/jquery-1.11.2.js" type="text/javascript"></script>
<script src="common/script/bootstrap.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="common/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="common/css/login.css">
<link rel="icon" href="common/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="common/favicon.ico" type="image/x-icon" />
<!--<div class="login-main" >

    <img src="common/css/images/login-back.png">

</div>
-->
<div class="login-form">
    <div class="login-logo">

        <img src="common/css/images/login-logo.png">
    </div>
    <div class="login-title"><div style="font-size: 30px">城市管家-代理终端</div>
        <div style="font-size: 18px;margin-top: 20%;margin-bottom: 20%" >欢迎登录城市管家-代理终端</div></div>
    <div class="form-div">
        <form class="form-horizontal" style="text-align: center" id="loginForm">
        	<input type="hidden" name="isWeb" value="true">
            <input type="text" maxlength="16" class="form-control" id="account" name="account"
                   placeholder="用户名" data-easyform="length:1 16;char-chinese;"
                   data-message="请输入1—16位汉字英文字母或数字"
            style="width: 90%; ">
            <input placeholder="密码" type="password" class="form-control " id="password" name="password" style="width: 90% ; margin-top: 20px"/>
        </form>
        <div class="show-message"><span></span></div>
        <div class="login-button"><span>登&nbsp;&nbsp;&nbsp;录</span></div>

    </div>



</div>

<script type="text/javascript" >
    $(document).ready(function () {
        $(".login-button").on("click",function () {
            login();
        })
        $(function(){
            document.onkeydown = function(e){
                var ev = document.all ? window.event : e;
                if(ev.keyCode==13) {

                   login();

                }
            }
        });
    })

    function login() {
        var password = $("#loginForm input[name=password]").val();
        var account = $("#loginForm input[name=account]").val();
        var isWeb = $("#loginForm input[name=isWeb]").val();
        $(".show-message span").html("");
        if(account == ""){
            $(".show-message span").html("请输入用户名！");
            return;
        }
        if(password == ""){
            $(".show-message span").html("请输入密码！");
            return;
        }

        $.ajax({
            url :  "<%=basePath%>s/sys/user/login",
            type : "post",
            data : {"password":password,"account":account,"isWeb" : isWeb},
            success :function (res) {
                if(res.opStatus == "0"){
                    //登录成功
                    window.location.href = "<%=basePath%>s/sys/user/home.cgi";
                }else{
                    $(".show-message span").html(res.msgDesc);
                }
            }

        });
    }

</script>



</body>
</html>